﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IEnumerator=System.Collections.IEnumerator;

namespace Nvigorate.Common
{
    internal class Iterator : IEnumerable<Number>
    {
        private Number _count = -1;

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }

        public IEnumerator<Number> GetEnumerator()
        {
            Number count = -1;
            while (count++ < _count)
                yield return count;
        }

        public static IEnumerable<Number> Go(Number count)
        {
            return new Iterator(count -1);
        }

        private Iterator(Number count)
        {
            _count = count;
        }
    }
}
